package game.players.cpu.opponent;

import java.util.Timer;

import utils.tasks.ExpireTask;

import com.uqbar.vainilla.DeltaState;

import game.ball.Possessed;
import game.ball.SoccerBall;
import game.players.SoccerPlayer;
import game.players.states.WithBall;

public class ServingCPUOppPlayer extends WithBall {

	public ServingCPUOppPlayer(SoccerPlayer player, SoccerBall ball) {
		super(player, ball);
		ball.setState(new Possessed(player,ball));
		Timer timer = new Timer();
		timer.schedule(new ExpireTask<ServingCPUOppPlayer>(this) {
			
			@Override
			public void run() {
				this.getCallBackClass().serve();
			}
			
		}, 6000);
	}

	@Override
	public void update(DeltaState deltaState) {}
	
	protected void serve() {
		if (this.getTeammates().isEmpty())
			this.setTeammates(this.getPlayer().getScene().getOpponents());
		this.getPlayer().setState(new PassingCPUOppPlayer(this.getPlayer(), this.getClosestMate()));
	}

	@Override
	public boolean isRight() {
		return false;
	}

	@Override
	public void loseTheBall() {
		// No aplica		
	}

}
